package org.gourpg.entity.menu;


import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.proxy.HibernateProxy;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Objects;

@Entity
@Getter
@Setter
@ToString
@RequiredArgsConstructor
/**
 * 菜单配置实体
 */
@Table(name = "menu_detail")
public class MenuDetail {
    /**
     * 菜单ID，菜单的主键
     */
    @Id
    private Long menuId;

    /**
     * 菜单上级ID，菜单的主键
     */
    private Integer menuParentId;

    /**
     * 菜单主功能的链接，点开之后就在主页显示
     */
    private String menuMainUrl;

    /**
     * 菜单名称，在主页标签中显示
     */
    private String menuName;

    /**
     * 菜单类型（暂无），字典：MENU_TYPE
     */
    private String menuType;

    /**
     * 菜单说明
     */
    private String menuRemark;


    @Override
    public final boolean equals(Object o) {
        if (this == o) return true;
        if (o == null) return false;
        Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
        Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
        if (thisEffectiveClass != oEffectiveClass) return false;
        MenuDetail that = (MenuDetail) o;
        return getMenuId() != null && Objects.equals(getMenuId(), that.getMenuId());
    }

    @Override
    public final int hashCode() {
        return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
    }
}
